//
//  IconTextField.m
//  Inforcollection
//
//  Created by macbook on 15/12/2.
//  Copyright © 2015年 oceansoft.liw. All rights reserved.
//

#import "IconTextField.h"

#define KIconHeight 25
#define KIconWidth 25

@implementation IconTextField

-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    
    if (self)
    {
        self.backgroundColor=[UIColor whiteColor];
        self.layer.masksToBounds=YES;
        self.layer.cornerRadius=6.0;
        [self customIconAndTextFieldWithFrame:frame];
    }
    return self;
}


-(void)customIconAndTextFieldWithFrame:(CGRect)frame
{
    self.icon=[[UIImageView alloc]init];
    
    self.icon.frame=CGRectMake(10,(frame.size.height-KIconHeight)/2, KIconWidth, KIconHeight);
    
    self.icon.contentMode=UIViewContentModeScaleAspectFit;
    
    [self addSubview:self.icon];
    
    self.textField=[[UITextField alloc]init];
    
    self.textField.clearButtonMode=UITextFieldViewModeWhileEditing;
    
    self.textField.frame=CGRectMake(CGRectGetMaxX(self.icon.frame)+10, (frame.size.height-KIconHeight)/2,frame.size.width-CGRectGetMaxX(self.icon.frame)-10,KIconHeight);
    
    [self addSubview:self.textField];
}
@end
